package com.fr.plugins.test.aspectjs;

import com.fr.chart.chartattr.ChartCollection;
import com.fr.stable.xml.XMLableReader;

public aspect TemplateProcessTracker {
    //声明一个pointcut，匹配你需要的方法
    pointcut TestTableDataContentPanePointCut() : execution(* com.fr.plugins.test.pane.TestTableDataContentPane.*(ChartCollection));
    pointcut XMLPointCut() : execution(* com.fr.plugins.test..*XML(..));

    before() : TestTableDataContentPanePointCut(){
    	
        System.out.println("进入:"+thisJoinPoint.getSignature().toString()); 
        Object[] args = thisJoinPoint.getArgs();
        for(int i = 0 ; i<args.length ; i++){
        	if(args[i] instanceof ChartCollection){
        		ChartCollection chartCollection = (ChartCollection)args[i];
        		System.out.println("ChartCollection当前图表是:"+chartCollection.getSelectedChart().getClass().getSimpleName());//获取图表类名
        		if(chartCollection.getSelectedChart().getFilterDefinition() !=null){
        			System.out.println("ChartCollection当前图表的数据集是:"+chartCollection.getSelectedChart().getFilterDefinition().getClass().getSimpleName());//获取图表数据集的类名
        		}else{
        			System.out.println("ChartCollection当前图表的数据集是:NULL");//获取图表数据集的类名
        		}
        	}
        }
    }  
    before() : XMLPointCut(){
    	System.out.println("XML操作:"+thisJoinPoint.getSignature().toString()); 
    	 Object[] args = thisJoinPoint.getArgs();
    	 if(args[0] instanceof XMLableReader){
    		 XMLableReader xmlLableReader  = (XMLableReader) args[0];
    		 System.out.println("tagName="+xmlLableReader.getTagName());
    		 if(xmlLableReader.isCharacters()){//判断某个子节点是否是文本
    			 System.out.println(xmlLableReader.getElementValue());
    			 System.out.println(xmlLableReader.getContent());
    			 
    		 }
    	 }
    }  
}
